import { PmsCategory } from "@/entity/PmsCategory";
import { ResponseResult } from "@/entity/ResponseResult";
import { AxiosResponse } from "axios";
import httpClient from "./http-client";
import { db_categories } from "@/database/category";

export class CategoryService {
    baseUrl = "/api/v1.0/portal/category";

    public async list(): Promise<PmsCategory[]> {
        return Promise.resolve(db_categories);
        return httpClient.get(`${this.baseUrl}/treelist`).then((res: AxiosResponse<ResponseResult<PmsCategory[]>>) => {
            if (res.data.data) {
                const list = res.data.data;
                return Promise.resolve(list);
            } else {
                throw "no data";
            }
        });
    }
}

const instance = new CategoryService();
export default instance;